<template>
  <div>
      <p>用户名：<input type="text" v-model="username"></p>
      <p>密码：<input type="text" v-model="password"></p>
      <p><button @click="login">登录</button></p>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            username:'',
            password:''
        }
    },

    methods:{
        login(){
            axios.get('http://127.0.0.1:8000/myapp/login/',{
                params:{username:this.username,password:this.password}
            }).then(res=>{
                console.log(res.data)
                if(res.data.code==200){
                    sessionStorage.setItem('uid',res.data.uid)
                    alert('登录成功')
                }
            })
        }
    }
}
</script>

<style>

</style>